clear all;

cd ..; cd ..; cd ..;
load('code_main_model\6_implied_w_r\computation_results\data.mat','sigma','V_backward','nmkt','pdf_B_forward',...
    'nb','ntheta','nz','gridb','gridtheta','gridz','nb_pdf','ntheta_pdf','gridb_pdf','gridtheta_pdf');
load('code_main_model\6_implied_w_r\input\comm_loc_model.mat','comm_loc_model');
cd 'code_figure_table\maintext\Figure 11';

index=find(comm_loc_model(:,1)==1); % with branch in 86

marketindex=index(1);
thetaindex=ntheta;
t_ini=1;
t_end=11;
V_ini=squeeze(V_backward(t_ini,marketindex,:,:,thetaindex));
V_new=squeeze(V_backward(t_end,marketindex,:,:,thetaindex));
welfare=(V_new./V_ini).^(1/(1-sigma))-1;
welfare=welfare.*100;

save('baseline\baselineB.mat');